/*
 * @Author: 黄达全
 * @Date: 2024-08-11 20:01:28
 * @LastEditTime: 2024-08-13 11:39:46
 */

import type {ApiResponse } from "@/common/type"

export interface AccessItem {
    id: number;
    ruleId: number;
    status: boolean | number;
    create_time: string;
    update_time: string;
    name: string;
    desc: string;
    frontpath: null;
    condition: null;
    menu: number;
    order: number;
    icon: string;
    method: string;
    child: AccessItem[] | [];
}

export interface AccessAddForm{
    ruleId: number,
    menu: number,
    name: string,
    condition:string,
    method: "GET" | "POST" | "PUT" | "DELETE",
    order:number,
    frontpath:string,
    icon:string
}
export interface AccessEditForm{
    status:number
    ruleId: number,
    menu: number,
    name: string,
    condition:string,
    method: "GET" | "POST" | "PUT" | "DELETE",
    order:number,
    frontpath:string,
    icon:string
}

export type RuleApi={
    select:()=>Promise<ApiResponse<AccessItem[]>>,
    add:(form:AccessAddForm)=>Promise<ApiResponse<null>>,
    edit:(id:number,form:AccessEditForm | {status:number})=>Promise<ApiResponse<null>>,
    delete:(id:number)=>Promise<ApiResponse<null>>
}